package com.quick.im.client;

import com.quick.im.client.component.NettyClientConfig;
import com.quick.im.common.util.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

@Slf4j
@SpringBootApplication
@MapperScan(value = "com.quick.im.client")
public class ClientApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(ClientApplication.class, args);
        SpringUtil.set(context);
    }

    @Bean
    public CommandLineRunner run(NettyClientConfig nettyClientConfig) {
        return args -> {
            log.info("Starting Netty Client...");
            nettyClientConfig.start();  // 启动客户端
        };
    }
}